package enums;


import org.apache.commons.lang3.StringUtils;

/**
 * @author ke
 * Created by on  2021-05-26 15:53
 */
public enum OperateTypeEnum {

    /**
     * 新增
     */
    INSERT("insert", "新增"),
    /**
     * 修改
     */
    UPDATE("update", "修改"),
    /**
     * 删除
     */
    DELETE("delete", "删除");

    private final String type;

    private final String name;

    public String getName() {
        return this.name;
    }

    public String getType() {
        return this.type;
    }

    OperateTypeEnum(String type,String name) {
        this.type = type;
        this.name = name;
    }

    public static OperateTypeEnum getByType(String type) {
        if (StringUtils.isEmpty(type)) {
            return null;
        }
        for (OperateTypeEnum typeEnum : values()) {
            if (type.equals(typeEnum.getType())) {
                return typeEnum;
            }
        }
        return null;
    }
}
